package org.mcjug.locationmailer.util;

import java.io.PrintWriter;
import java.io.StringWriter;

import android.os.Parcel;
import android.os.Parcelable;

public class ParcelableException implements Parcelable {

	private String message;
    public ParcelableException() {
        super();
    }

    public ParcelableException(Throwable throwable) {
    	StringWriter strWriter = new StringWriter();
    	PrintWriter writer = new PrintWriter(strWriter);
    	
    	throwable.printStackTrace(writer);
    	
    	message = strWriter.toString();
    }

    public ParcelableException(Parcel parcel) {
    	message = parcel.readString();
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel parcel, int ignored) {
        parcel.writeString(getMessage());
    }
    
    
    public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public static final Parcelable.Creator<ParcelableException> CREATOR = new Parcelable.Creator<ParcelableException>() {

        public ParcelableException createFromParcel(Parcel parcel) {
            return new ParcelableException(parcel);
        }

        public ParcelableException[] newArray(int size) {
            return new ParcelableException[size];
        }
    };

}
